/*禁止右键*/
function iEsc() {
    return false;
}

function iRec() {
    return true;
}

document.oncontextmenu = iEsc;
if (typeof document.onselectstart != "undefined")
    document.onselectstart = iEsc;
else {
    document.onmousedown = iEsc;
    document.onmouseup = iRec;
}
$(".softwares").contextmenu(function (ev) {
    var oEvent = ev || event;
    openRightKeyWindow(oEvent);
});

function openRightKeyWindow(oEvent) {
    var html = '<div id="rightMenu" class="panel rightMenu height-100">' +
        '<ul>' +
        '    <li><i class="fa fa-fw fa-star"></i>收藏本页</li>\n' +
        '    <li onclick="fullScreen()"><i class="fa fa-fw fa-window-maximize"></i>进入全屏</li>\n' +
        '    <li onclick="exitFullScreen()"><i class="fa fa-fw fa-window-restore"></i>退出全屏</li>\n' +
        '</ul>' +
        '</div>';

    if ($("#rightMenu").length > 0) {
        $("#rightMenu").css("left", oEvent.clientX);
        $("#rightMenu").css("top", oEvent.clientY);
        $("#rightMenu").show();
    } else {
        $(".softwares").append(html);
        $("#rightMenu").css("left", oEvent.clientX);
        $("#rightMenu").css("top", oEvent.clientY);
        $("#rightMenu").show();
    }
}

$("body").click(function () {
    $("#rightMenu").animate(100).hide();
})



function fullScreen() {

    var docElm = document.documentElement;
//W3C
    if (docElm.requestFullscreen) {
        docElm.requestFullscreen();
    }
//FireFox
    else if (docElm.mozRequestFullScreen) {
        docElm.mozRequestFullScreen();
    }
//Chrome等
    else if (docElm.webkitRequestFullScreen) {
        docElm.webkitRequestFullScreen();
    }
//IE11
    else if (elem.msRequestFullscreen) {
        elem.msRequestFullscreen();
    }

}
function exitFullScreen() {
    document.addEventListener("fullscreenchange", function () {
        fullscreenState.innerHTML = (document.fullscreen)? "" : "not ";}, false);
    document.addEventListener("mozfullscreenchange", function () {
        fullscreenState.innerHTML = (document.mozFullScreen)? "" : "not ";}, false);
    document.addEventListener("webkitfullscreenchange", function () {
        fullscreenState.innerHTML = (document.webkitIsFullScreen)? "" : "not ";}, false);
    document.addEventListener("msfullscreenchange", function () {
        fullscreenState.innerHTML = (document.msFullscreenElement)? "" : "not ";}, false);
    if (document.exitFullscreen) {
        document.exitFullscreen();
    }
    else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    }
    else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
    }
    else if (document.msExitFullscreen) {
        document.msExitFullscreen();
    }
}

$(document).keydown(function(event){

   /* alert(event.keyCode);*/
    if(event.keyCode==122){
        fullScreen()
        return false;
    }

});